'''From this reddit comment by shaurz
http://www.reddit.com/r/Python/comments/by982/please_help_with_a_silly_matrix_question/c0p5uh2
'''

def matrix(x, *dim, default=0):
    '''
    Creates a matrix formed of lists with arbitary dimensions, filled with zeroes

    m = make_matrix(3, 3, 3)
    print m
        [[[0, 0, 0], [0, 0, 0], [0, 0, 0]],
        [[0, 0, 0], [0, 0, 0], [0, 0, 0]],
        [[0, 0, 0], [0, 0, 0], [0, 0, 0]]]

    make_matrix(3, 3, 3, default=1)
    print m
        [[[1, 1, 1], [1, 1, 1], [1, 1, 1]],
        [[1, 1, 1], [1, 1, 1], [1, 1, 1]],
        [[1, 1, 1], [1, 1, 1], [1, 1, 1]]]
    '''
    if dim:
        return [make_matrix(*dim) for _ in xrange(x)]
    else:
        return [default] * x
